package com.ruoyi.common.constant;

/**
 * 数字字符串常量类
 * 包含从"0"到"10"的字符串常量定义
 */
public final class DigitStringConstants {

    // 防止类被实例化
    private DigitStringConstants() {}

    /** 负一 "-1" */
    public static final String NEGATIVE_ONE = "-1";
    /** 字符串 "0" */
    public static final String ZERO = "0";
    /** 字符串 "1" */
    public static final String ONE = "1";
    /** 字符串 "2" */
    public static final String TWO = "2";
    /** 字符串 "3" */
    public static final String THREE = "3";
    /** 字符串 "4" */
    public static final String FOUR = "4";
    /** 字符串 "4.005" */
    public static final String FOUR_POINT_ZERO_ZERO_FIVE = "4.005";
    /** 字符串 "5" */
    public static final String FIVE = "5";
    /** 字符串 "6" */
    public static final String SIX = "6";
    /** 字符串 "7" */
    public static final String SEVEN = "7";
    /** 字符串 "8" */
    public static final String EIGHT = "8";
    /** 字符串 "9" */
    public static final String NINE = "9";
    /** 字符串 "10" */
    public static final String TEN = "10";

    /** 所有数字字符串常量的数组 */
    public static final String[] ALL_DIGITS = {
            ZERO, ONE, TWO, THREE, FOUR, FIVE, SIX, SEVEN, EIGHT, NINE, TEN
    };

    /**
     * 获取指定索引的数字字符串
     * @param index 索引值(0-10)
     * @return 对应的数字字符串，超出范围返回null
     */
    public static String get(int index) {
        if (index >= 0 && index < ALL_DIGITS.length) {
            return ALL_DIGITS[index];
        }
        return null;
    }

    /**
     * 判断字符串是否为0-10之间的数字字符串
     * @param str 待检查的字符串
     * @return true如果是0-10之间的数字字符串，否则false
     */
    public static boolean isDigitString(String str) {
        for (String digit : ALL_DIGITS) {
            if (digit.equals(str)) {
                return true;
            }
        }
        return false;
    }

    /**
     * 将数字字符串转换为对应的整数
     * @param str 数字字符串(0-10)
     * @return 对应的整数值，无效字符串返回-1
     */
    public static int toInt(String str) {
        for (int i = 0; i < ALL_DIGITS.length; i++) {
            if (ALL_DIGITS[i].equals(str)) {
                return i;
            }
        }
        return -1;
    }
}
